package com.api.devices.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.api.common.utils.DateUtils;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Getter
@Setter
public class DevicesScoreVo {
    private Long plcId;
    private Long lineId;
    private Long robotId;
    private Long elementId;
    private String datCol;
    private Double Score;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;
    private String appLang;

    public void setStartTime(Date startTime) {
        this.startTime = DateUtils.addHours(startTime, 8);
    }

    public Date getStartTime() {
        if (startTime == null) {
//            return DateUtils.addHours(new Date(), 8);
            return DateUtils.addHours(new Date(), -30 * 24);
        }
        return startTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = DateUtils.addHours(endTime, 8);
    }

    public Date getEndTime() {
        if (endTime == null) {
            return DateUtils.addHours(new Date(), 8);
        }
        return endTime;
    }
}
